﻿<UserControl x:Class="KarateSemaphore.Phone.PointControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:core="clr-namespace:KarateSemaphore.Core;assembly=KarateSemaphore.Core"
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    xmlns:ei="clr-namespace:Microsoft.Expression.Interactivity.Media;assembly=Microsoft.Expression.Interactions"
    mc:Ignorable="d"
    d:DataContext="{d:DesignInstance core:CompetitorViewModel, IsDesignTimeCreatable=True}"
    d:DesignHeight="200" d:DesignWidth="200">

    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Style.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid>

        <Grid.Resources>
            <Storyboard x:Name="awardPopupShow">
                <ObjectAnimationUsingKeyFrames 
                    Duration="0" 
                    Storyboard.TargetName="awardPopup" 
                    Storyboard.TargetProperty="Visibility">
                    <DiscreteObjectKeyFrame KeyTime="0">
                        <DiscreteObjectKeyFrame.Value>
                            <Visibility>Visible</Visibility>
                        </DiscreteObjectKeyFrame.Value>
                    </DiscreteObjectKeyFrame>
                </ObjectAnimationUsingKeyFrames>
                <ObjectAnimationUsingKeyFrames 
                    Duration="0" 
                    Storyboard.TargetName="scoreDisplay" 
                    Storyboard.TargetProperty="Visibility">
                    <DiscreteObjectKeyFrame KeyTime="0">
                        <DiscreteObjectKeyFrame.Value>
                            <Visibility>Collapsed</Visibility>
                        </DiscreteObjectKeyFrame.Value>
                    </DiscreteObjectKeyFrame>
                </ObjectAnimationUsingKeyFrames>
            </Storyboard>
            <Storyboard x:Name="awardPopupHide">
                <ObjectAnimationUsingKeyFrames 
                    Duration="0" 
                    Storyboard.TargetName="awardPopup" 
                    Storyboard.TargetProperty="Visibility">
                    <DiscreteObjectKeyFrame KeyTime="0">
                        <DiscreteObjectKeyFrame.Value>
                            <Visibility>Collapsed</Visibility>
                        </DiscreteObjectKeyFrame.Value>
                    </DiscreteObjectKeyFrame>
                </ObjectAnimationUsingKeyFrames>
                <ObjectAnimationUsingKeyFrames 
                    Duration="0" 
                    Storyboard.TargetName="scoreDisplay" 
                    Storyboard.TargetProperty="Visibility">
                    <DiscreteObjectKeyFrame KeyTime="0">
                        <DiscreteObjectKeyFrame.Value>
                            <Visibility>Visible</Visibility>
                        </DiscreteObjectKeyFrame.Value>
                    </DiscreteObjectKeyFrame>
                </ObjectAnimationUsingKeyFrames>
            </Storyboard>
        </Grid.Resources>


        <Grid x:Name="scoreDisplay" Visibility="Visible">
            <Viewbox>
                <TextBlock Text="{Binding Path=Points}" Style="{StaticResource ResourceKey=panelText}"/>
            </Viewbox>
            <Button Content="" BorderThickness="0">
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="Click">
                        <ei:ControlStoryboardAction Storyboard="{StaticResource awardPopupShow}"/>
                    </i:EventTrigger>
                </i:Interaction.Triggers>
            </Button>
        </Grid>
        <StackPanel x:Name="awardPopup" Visibility="Collapsed" Width="Auto" HorizontalAlignment="Stretch">
            <Button Content="1" Command="{Binding ChangePoints}">
                <Button.CommandParameter><core:Award>Yuko</core:Award></Button.CommandParameter>
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="Click">
                        <ei:ControlStoryboardAction Storyboard="{StaticResource awardPopupHide}"/>
                    </i:EventTrigger>
                </i:Interaction.Triggers>
            </Button>
            <Button Content="2" Command="{Binding ChangePoints}">
                <Button.CommandParameter><core:Award>WazaAri</core:Award></Button.CommandParameter>
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="Click">
                        <ei:ControlStoryboardAction Storyboard="{StaticResource awardPopupHide}"/>
                    </i:EventTrigger>
                </i:Interaction.Triggers>
            </Button>
            <Button Content="3" Command="{Binding ChangePoints}">
                <Button.CommandParameter><core:Award>Ippon</core:Award></Button.CommandParameter>
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="Click">
                        <ei:ControlStoryboardAction Storyboard="{StaticResource awardPopupHide}"/>
                    </i:EventTrigger>
                </i:Interaction.Triggers>
            </Button>
        </StackPanel>
    </Grid>
</UserControl>